WPF and Silverlight Edition Basic Library > NumericBox > NumericBox Elements > Locking the Control from Editing |
By default the C1NumericBox control's Value property is editable by users at run time. If you want to lock the control from being edited, you can set the IsReadOnly property to True.
To lock the C1NumericBox control in XAML add IsReadOnly="True" to the <c1:C1NumericBox> tag so that it appears similar to the following:
XAML |
Copy Code
|
---|---|
<c1:C1NumericBox Name="C1NumericBox1" IsReadOnly="True" /> |
To lock the C1NumericBox control from run-time editing in code, add the following to your project:
Visual Basic |
Copy Code
|
---|---|
C1NumericBox1.IsReadOnly = True |
C# |
Copy Code
|
---|---|
c1NumericBox1.IsReadOnly = true;
|
To lock the C1NumericBox control from run-time editing, complete the following steps:
This will set the IsReadOnly property to False.
Run your project and observe:
The control is locked from editing; notice that the Up and Down buttons are grayed out and inactive: